package com.cduestc.mylogin;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.pojo.Login;

public class MyIndex extends Activity{
	TextView tvinfo;
	Button btnBack;
	//TextView tv;
	SharedPreferences shareGet;
		
		protected void onCreate(Bundle savedInstanceState) {
			
			// TODO Auto-generated method stub
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.index);
			
			tvinfo = (TextView) this.findViewById(R.id.tv1);
			btnBack = (Button) this.findViewById(R.id.btnBack);
			shareGet = this.getSharedPreferences("selfMsg",MODE_PRIVATE);

			Intent intent = this.getIntent();
			Bundle bun = intent.getExtras();
			Login login = (Login) bun.getSerializable("login");
			//Login login1 = (Login) bun.getSerializable("login1");
			//String info = login.getUsername()+"  "+login.getPassword();
			//String e = login1.getEamilnum();
			//String p = login1.getPhone();
			//String s = login1.getAge() + "岁";
			 String e = shareGet.getString("email","");
			 String p = shareGet.getString("phone","");
			 String b = shareGet.getString("birth","");
			if(e.equals("")){
				e = "未绑定";
			}
			if(p.equals("")){
				p = "未绑定";
			}
			if(b.equals("")){
				b = "未设置";
			}

			tvinfo.setText("账号：" +login.getUsername() + "\n" + "密码：" + login.getPassword() +
							"\n" + "性别：" + login.getSex() + "\n" + "年龄：" + SelfMessage.recodeage + "岁" + "\n" + "爱好：" + login.getHobbys() +
					"\n" + "邮箱：" + e + "\n" + "手机：" + p + "\n" + "生日：" + b
			);
		
		//返回
			btnBack.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent2 = new Intent(MyIndex.this,HomePage.class);
				startActivity(intent2);
			}
		});
	}

}
